//
//  FavoriteGoodsCell.m
//  phmall
//
//  Created by admin on 2018/1/7.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "FavoriteGoodsCell.h"

@implementation FavoriteGoodsCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self){
        self.contentView.backgroundColor=[UIColor whiteColor];
        self.cellImage=[[UIImageView alloc]init];
        self.cellImage.image=[UIImage imageNamed:@"图片"];
        [self.contentView addSubview:self.cellImage];
        
        self.name=[[UILabel alloc]init];
        self.name.text=@"YSL玫瑰色口红(新款)";
        self.name.numberOfLines=2;
        self.name.textColor=[UIColor colorWithHexString:@"#121212"];
        self.name.font=[UIFont systemFontOfSize:13];
        [self.contentView addSubview:self.name];
        
        self.price=[[UILabel alloc]init];
        self.price.font=[UIFont systemFontOfSize:15];
        self.price.text=@"6666.00";
        self.price.textColor=[UIColor orangeColor];
        [self.contentView addSubview:self.price];
        
        self.more=[UIButton  buttonWithType:UIButtonTypeCustom];
        [self.more setImage:[UIImage imageNamed:@"垃圾箱"] forState:UIControlStateNormal];
        [self.contentView addSubview:self.more];
        [self.more addTarget:self action:@selector(moreAction:) forControlEvents:UIControlEventTouchUpInside];
        
        self.contentView.layer.borderWidth=0.5;
        self.contentView.layer.borderColor=[UIColor colorWithHexString:@"#efeff4"].CGColor;
    }
    
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.contentView.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    
    [self.cellImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).with.offset(0);
        make.left.equalTo(self.contentView).with.offset(0);
        make.right.equalTo(self.contentView).with.offset(0);
        make.height.equalTo(self.cellImage.mas_width);
    }];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.cellImage.mas_bottom).with.offset(10);
        make.left.equalTo(self.contentView).with.offset(15);
        make.right.equalTo(self.contentView).with.offset(-15);
    }];
    
    
    [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(15);
        make.bottom.equalTo(self.contentView).with.offset(-10);
    }];
    
    [self.more mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).with.offset(-10);
        make.centerY.equalTo(self.price);
        make.width.height.offset(40);
    }];
}
-(void)moreAction:(UIButton *)sender{
    if (self.delegate && [self.delegate respondsToSelector:@selector(removeAction:)]) {
        [self.delegate removeAction:self];
    }
}
-(void)setModel:(GoodsModel *)model{
    _model=model;
    [self.cellImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@union/%@",IMGURL,model.goods_file1]] placeholderImage:[UIImage imageNamed:@"图片空白页"]];
    self.name.text=model.goods_name;
    
    self.price.text=[NSString stringWithFormat:@"₱%@",model.goods_sale_price];
}
@end
